using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using QLKS.HeThongBUS;

namespace QLKS
{
    public partial class InHD : DevComponents.DotNetBar.Office2007Form
    {
        public InHD()
        {
            InitializeComponent();
        }

        private void InHD_Load(object sender, EventArgs e)
        {
            string maph = "101"; int mahd = 1;
            DataTable dt = InHD_BUS.ThongTinHD(maph,mahd);
            
           // dscmd.Fill(ds, "TTHoaDon");
            //MessageBox.Show(ds.Tables[1].Rows.Count.ToString());
           // cnn.Close();
            TTHoaDon ds = new TTHoaDon();
            DataTable t = ds.Tables.Add("Items");
            t.Columns.Add("MaPhong", Type.GetType("System.String"));
            t.Columns.Add("NgayThue", Type.GetType("System.String"));
            t.Columns.Add("NgayTra", Type.GetType("System.String"));
            t.Columns.Add("SoNguoi", Type.GetType("System.String"));
            t.Columns.Add("TienPhong", Type.GetType("System.String"));
            t.Columns.Add("TenDV", Type.GetType("System.String"));
            t.Columns.Add("SoLuong", Type.GetType("System.String"));
            t.Columns.Add("TienDV", Type.GetType("System.String"));
            t.Columns.Add("KhachDK", Type.GetType("System.String"));
            t.Columns.Add("ThanhTien", Type.GetType("System.String"));
            t.Columns.Add("TenNhanVien", Type.GetType("System.String"));

            DataRow r;
           
            
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow dr = dt.Rows[i];
                r = t.NewRow();
                r["MaPhong"] = dr["MaPhong"].ToString();
                r["NgayThue"] = DateTime.Parse(dr["NgayThuePhong"].ToString()).ToShortDateString();
                r["NgayTra"] = DateTime.Parse(dr["NgayTraPhong"].ToString()).ToShortDateString();
                r["SoNguoi"] = Int32.Parse(dr["SoLuongNguoi"].ToString());
                r["TienPhong"] = dr["TienThuePhong"].ToString();
                r["TenDV"] = dr["TenDichVu"].ToString();
                r["TienDV"] = dr["TienDichVu"].ToString();
                r["SoLuong"] = Int32.Parse(dr["SoLuong"].ToString());
                r["KhachDK"] = dr["TenKhachHang"].ToString();
                r["ThanhTien"] = Int32.Parse(dr["ThanhTien"].ToString());
                r["TenNhanVien"] = dr["TenNhanVien"].ToString();
                t.Rows.Add(r);
            }

            InHoaDon objRpt = new InHoaDon();
            objRpt.SetDataSource(ds.Tables[1]);
            crystalReportViewer1.ReportSource = objRpt;
            crystalReportViewer1.Refresh();

        }
    }
}